package test;

import DTO.UserDTO;
import PO.User;
import com.google.common.collect.Lists;
import mapstruct.UserMapper;
import org.modelmapper.ModelMapper;
import utils.Utils;

import java.util.List;

/**
 * @ProjectName: util
 * @Package: test
 * @ClassName: ${TYPE_NAME}
 * @Description:
 * @Author: haifeng.mi
 * @CreateDate: 2018/10/11 10:52
 * @UpdateUser: haifeng.mi
 * @UpdateDate: 2018/10/11 10:52
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * Copyright: Copyright (c) 2018
 */
public class BitData {


    public static void main(String[] args) {
        List<User> userList = Lists.newArrayList();

        final String userLoginId = "123456";
        final String userName = "米咕咕";
        final String password = "******";
        final String qq = "315630939";
        final String ecmail = "mhf3419@163.com";
        final String remark = "mark";

        for (int i = 0; i < 100000; i++) {
            User user = new User();
            user.setUserLoginId(String.valueOf(i));
            user.setUserName(userName);
            user.setPassword(password);
            user.setQq(qq);
            user.setEmail(ecmail);
            user.setRemark(remark);

            userList.add(user);
        }

        final long starttime = System.currentTimeMillis();
        final List<UserDTO> userDTOList = UserMapper.MAPPER.userToUserDTOs(userList);
        final long endTime = System.currentTimeMillis();
        System.out.println("mapstruct十万条数据ms:" + (endTime - starttime));


        final long starttime1 = System.currentTimeMillis();
        List<UserDTO> userDTOS = Lists.newArrayList();
        final List<UserDTO> userDTOList1 = Utils.populateList(userList, userDTOS, UserDTO.class);
        final long endTime1 = System.currentTimeMillis();
        System.out.println("反射十万条数据ms:" + (endTime1 - starttime1));


        final long starttime2 = System.currentTimeMillis();
        List<UserDTO> userDTOS1 = Lists.newArrayList();
        ModelMapper modelMapper = new ModelMapper();
        for (User user : userList) {
            userDTOS1.add(modelMapper.map(user, UserDTO.class));
        }
        final long endTime2 = System.currentTimeMillis();
        System.out.println("ModelMapper十万条数据ms:" + (endTime2 - starttime2));

    }
}
